#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 25;

int n, m;
int ans[N], num;
void dfs(int x, int sl, int sm, int sr) {
  if (x == n + 1) {
    num++;
    if (num <= 3) {
      rep(i, 1, n) cout << ans[i] << ' ';
      cout << endl;
    }
    return;
  }
  int s = sl | sm | sr;
  rep(i, 0, n - 1) {
    int j = 1 << i;
    if (s & j) continue;
    ans[x] = i + 1;
    dfs(x + 1, (sl | j) >> 1, sm | j, (sr | j) << 1);
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  dfs(1, 0, 0, 0);
  cout << num;
  return 0;
}